<template>
	<view>
		<van-tabbar :active="actives" @change="onClick">
			<van-tabbar-item v-for="(item, index) in tabbarData" :key="item.index"  :icon="item.icon">{{item.name}}</van-tabbar-item>
		</van-tabbar>
	</view>
</template>

<script>
	import badgeMix from '@/mixins/tabbar-badge.js'
	export default {
		mixins:[badgeMix],
		name:"tabbar-component",
		props:{
			actives:{
				type:Number,
				default:0
			}
		},
		data() {
			return {
				tabbarData:[
					{
						index:0,
						name:'首页',
						url:'/pages/index/index',
						icon:'home-o'
					},
					{
						index:1,
						name:'商城',
						url:'/pages/mall/mall',
						icon:'search'
					},
					{
						index:2,
						name:'学习',
						url:'/pages/study/study',
						icon:'friends-o'
					},
					{
						index:3,
						name:'我的',
						url:'/pages/me/me',
						icon:'setting-o'
					}
				]
			};
		},
		onLoad() {
		},
		methods:{
			onClick(event) {
				uni.setStorageSync('bgNumber', event.detail)
				uni.switchTab({
				    url: this.tabbarData[event.detail].url
				})
			},
		}
	}
</script>

<style lang="scss">

</style>